//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    h5Url:"http://localhost:9483/#/",
    shortLink:"",
    showH5: true,
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    app:null
  },
  onReady: function(){
    console.log('onReady')
    wx.navigateTo({
      url: `/pages/h5/index?showH5=1&h5Url=${this.data.h5Url}`,
    })
  },
  onLoad: function (options) {
    console.log('首页onLoad options = ')
    console.log(options)
    var h5Url = options.h5Url
    h5Url = h5Url? h5Url: this.data.h5Url

    if(h5Url && h5Url.indexOf('https://')!=-1){
      h5Url = encodeURIComponent(h5Url)
    }
    this.setData({
      h5Url: h5Url
    })

    console.log('index onload this.data= ')
    console.log(this.data)




    console.log('🚀🚀🚀🚀🚀小程序启动了')

    
    this.setData({
      app:getApp()
    })

    
},
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
 onTap: function(){
  wx.navigateTo({
    url: '/pages/h5/index?showH5=1',
  })
 },

  
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
    getPhoneNumber:
        function (e) {
            console.log(e)
            var code = e.detail.code


            wx.navigateTo({
                url: 'h5?wxCode='+code,
            })

        }

})




// 获取本地保存的 token
function isUserLoggedIn() {
    var token = wx.getStorageSync('token');
    return token
}



